from PyQt4 import QtCore, QtGui;

class ActionCmds(QtCore.QObject):
    def __init__(self, parent, graphScene, graphView):
        super(ActionCmds, self).__init__();
        self.parent = parent;
        self.mainWin = parent.mainWin;
        self.graphScene = graphScene;
        self.graphView = graphView;
        self.dataContainer = parent.dataContainer;
        self.dataView = parent.dataContainer.dataView;
        self.dataModel = parent.dataContainer.dataModel;
        self.createActionCmds();
        
    
    def createActionCmds(self):
        #File Actions
        self.actionNewGraph = QtGui.QAction(QtGui.QIcon('Images/new_Mdp.png'), 'New Graph', self.parent);
        self.actionLoadProject = QtGui.QAction(QtGui.QIcon('Images/open_Project.png'), 'Load Project...', self.parent);
        self.actionLoadGraph = QtGui.QAction(QtGui.QIcon('Images/open_Mdp.png'), 'Load...', self.parent);
        self.actionLoadSettings = QtGui.QAction(QtGui.QIcon('Images/open_Project.png'), 'Load Settings...', self.parent);
        self.actionSaveProject = QtGui.QAction(QtGui.QIcon('Images/save_Project.png'), 'Save Project', self.parent);
        self.actionSaveGraph = QtGui.QAction(QtGui.QIcon('Images/save_Mdp.png'), 'Save', self.parent);
        self.actionSaveGraphAs = QtGui.QAction('Save as...', self.parent);
        self.actionSaveSettings = QtGui.QAction(QtGui.QIcon('Images/save_Project.png'), 'Save Settings...', self.parent);
        self.actionExit = QtGui.QAction(QtGui.QIcon('Images/exit.png'), "Exit", self.parent.mainWin);
        QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), self.parent.mainWin.close);
        QtCore.QObject.connect(self.actionNewGraph, QtCore.SIGNAL("triggered()"), self.newGraph);
        QtCore.QObject.connect(self.actionLoadGraph, QtCore.SIGNAL("triggered()"), self.loadGraphData);
        QtCore.QObject.connect(self.actionSaveGraph, QtCore.SIGNAL("triggered()"), self.saveGraphData);
        QtCore.QObject.connect(self.actionSaveGraphAs, QtCore.SIGNAL("triggered()"), self.saveGraphDataAs);
        QtCore.QObject.connect(self.actionLoadSettings, QtCore.SIGNAL("triggered()"), self.loadSettingsData);
        QtCore.QObject.connect(self.actionSaveSettings, QtCore.SIGNAL("triggered()"), self.saveSettingsData);
        
        #Edit Actions
        self.undoStack = self.parent.undoStack;
        self.actionUndo = self.undoStack.createUndoAction(self.parent);
        self.actionRedo = self.undoStack.createRedoAction(self.parent);
        self.actionUndo.setIcon(QtGui.QIcon('Images/undo.png'));
        self.actionRedo.setIcon(QtGui.QIcon('Images/redo.png'));
        self.actionUndo.setShortcut('Ctrl+Z');
        self.actionRedo.setShortcut('Ctrl+Y');
        self.actionEditNodeInfo = QtGui.QAction(QtGui.QIcon('Images/edit_NodeInfo.png'), 'Edit Node Information...', self.parent);
        self.actionAddNode = QtGui.QAction(QtGui.QIcon('Images/add_Node.png'), 'Add Node', self.parent);
        self.actionEditEdgeInfo = QtGui.QAction(QtGui.QIcon('Images/edit_EdgeInfo.png'), 'Edit Edge Information...', self.parent);
        self.actionShowCtrlPts = QtGui.QAction(QtGui.QIcon('Images/show_CtrlPts.png'), 'Show Edge Control Points', self.parent);
        self.actionAddCtrlPt = QtGui.QAction(QtGui.QIcon('Images/add_CtrlPt.png'), 'Add Edge Control Point', self.parent); 
        self.actionDelete = QtGui.QAction(QtGui.QIcon('Images/erase.png'), 'Delete', self.parent);     
        self.actionSelectGraph = QtGui.QAction('Select Graph', self.parent);
        self.actionSelectNodes = QtGui.QAction('Select Nodes', self.parent);
        self.actionSelectNodesByDim = QtGui.QAction('Select Nodes By Dimension...', self.parent);
        self.actionSelectActions = QtGui.QAction('Select Actions', self.parent);
        self.actionSelectEdges = QtGui.QAction('Select Edges', self.parent);
        QtCore.QObject.connect(self.actionAddNode, QtCore.SIGNAL('triggered()'), self.graphScene.createNode);
        QtCore.QObject.connect(self.actionDelete, QtCore.SIGNAL('triggered()'), self.graphScene.deleteSelectedItems);
        QtCore.QObject.connect(self.actionShowCtrlPts, QtCore.SIGNAL('triggered()'), self.graphScene.showSelCtrlPts);
        QtCore.QObject.connect(self.actionSelectGraph, QtCore.SIGNAL('triggered()'), self.selectGraph);
        QtCore.QObject.connect(self.actionSelectNodes, QtCore.SIGNAL('triggered()'), self.selectNodes);
        QtCore.QObject.connect(self.actionSelectEdges, QtCore.SIGNAL('triggered()'), self.selectEdges);
        QtCore.QObject.connect(self.actionSelectActions, QtCore.SIGNAL('triggered()'), self.selectActions);
        QtCore.QObject.connect(self.actionAddCtrlPt, QtCore.SIGNAL('triggered()'), self.addEdgeCtrlPt);
        
        #View Actions
        self.actionGraph = QtGui.QAction(QtGui.QIcon('Images/show_Graph.png'), 'Graph Window', self.parent);
        self.actionGraphSettings = QtGui.QAction('Graph Settings...', self.parent);
        self.actionToolbar = QtGui.QAction('Hide Toolbar', self.parent);
        self.actionToolbar.setCheckable(True);
        self.actionFullScreen = QtGui.QAction(QtGui.QIcon('Images/full_Screen.png'), 'Full Screen', self.parent);
        self.actionFullScreen.setCheckable(True);
        self.actionTbl_GrpActVals = QtGui.QAction('Group Activities Table', self.parent);
#         self.actionTbl_MdpAndRisks = QtGui.QAction('MDP and Risks Info', self.parent);
#         self.actionTbl_StateInfo = QtGui.QAction('State Information', self.parent);
#         self.actionTbl_StateTrans = QtGui.QAction('Transitions Table', self.parent);
#         self.actionTbl_StateDists = QtGui.QAction('Distances Table', self.parent);
#         self.actionTbl_RiskActRes = QtGui.QAction('Risk Actions Results', self.parent);
#         self.actionTbl_MdpTraceEv = QtGui.QAction('Trace Events', self.parent);
#         self.actionTbl_GralMdpVals = QtGui.QAction('Gral MDP Parameters', self.parent);
        self.actionZoomIn = QtGui.QAction(QtGui.QIcon('Images/zoom_In.png'), 'Zoom In', self.parent);
        self.actionZoomOut = QtGui.QAction(QtGui.QIcon('Images/zoom_Out.png'), 'Zoom Out', self.parent);
        self.actionZoomReset = QtGui.QAction(QtGui.QIcon('Images/zoom_Reset.png'), 'Zoom to 100%', self.parent);
        self.actionSt_AllInfo = QtGui.QAction('All Info', self.parent);
        self.actionSt_HideV = QtGui.QAction('Hide Value', self.parent);
        self.actionSt_HideR = QtGui.QAction('Hide Reward', self.parent);
        self.actionSt_OnlyR = QtGui.QAction('Only Reward', self.parent);
        self.actionSt_OnlyV = QtGui.QAction('Only Value', self.parent);
        self.actionSt_OnlyDim = QtGui.QAction('Only State Dimensions', self.parent);
        self.actionSt_NoInfo = QtGui.QAction('No Info', self.parent);
        self.actionEdge_AllInfo = QtGui.QAction('All Info', self.parent);
        self.actionEdge_OnlyProb = QtGui.QAction('Only Probability', self.parent);
        self.actionEdge_OnlyR = QtGui.QAction('Only Reward', self.parent);
        self.actionEdge_NoInfo = QtGui.QAction('No Info', self.parent);
        self.actionAct_OnlyQ = QtGui.QAction('Only Q', self.parent);
        self.actionAct_OnlyId = QtGui.QAction('Only Id', self.parent);
        self.actionAct_NoInfo = QtGui.QAction('No Info', self.parent);
        QtCore.QObject.connect(self.actionTbl_GrpActVals, QtCore.SIGNAL('triggered()'), self.showGrpActVals);
#         QtCore.QObject.connect(self.actionTbl_MdpAndRisks, QtCore.SIGNAL('triggered()'), self.showMdpAndRisks);
#         QtCore.QObject.connect(self.actionTbl_StateInfo, QtCore.SIGNAL('triggered()'), self.showStateInfo);
#         QtCore.QObject.connect(self.actionTbl_StateTrans, QtCore.SIGNAL('triggered()'), self.showStateTrans);
#         QtCore.QObject.connect(self.actionTbl_StateDists, QtCore.SIGNAL('triggered()'), self.showStateDists);
#         QtCore.QObject.connect(self.actionTbl_RiskActRes, QtCore.SIGNAL('triggered()'), self.showRiskActRes);
#         QtCore.QObject.connect(self.actionTbl_MdpTraceEv, QtCore.SIGNAL('triggered()'), self.showMdpTraceEv);        
#         QtCore.QObject.connect(self.actionTbl_GralMdpVals, QtCore.SIGNAL('triggered()'), self.showGralMdpVals); 
        QtCore.QObject.connect(self.actionFullScreen, QtCore.SIGNAL('triggered()'), self.showFullScreenMode);
        QtCore.QObject.connect(self.actionZoomIn, QtCore.SIGNAL('triggered()'), self.graphView.zoomIn);
        QtCore.QObject.connect(self.actionZoomOut, QtCore.SIGNAL('triggered()'), self.graphView.zoomOut);
        QtCore.QObject.connect(self.actionZoomReset, QtCore.SIGNAL('triggered()'), self.graphView.zoomReset);        
        QtCore.QObject.connect(self.actionSt_AllInfo, QtCore.SIGNAL('triggered()'), self.setInfoStyleSt_AllInfo);
        QtCore.QObject.connect(self.actionSt_HideV, QtCore.SIGNAL('triggered()'), self.setInfoStyleSt_HideV);
        QtCore.QObject.connect(self.actionSt_HideR, QtCore.SIGNAL('triggered()'), self.setInfoStyleSt_HideR);
        QtCore.QObject.connect(self.actionSt_OnlyR, QtCore.SIGNAL('triggered()'), self.setInfoStyleSt_OnlyR);
        QtCore.QObject.connect(self.actionSt_OnlyV, QtCore.SIGNAL('triggered()'), self.setInfoStyleSt_OnlyV);
        QtCore.QObject.connect(self.actionSt_OnlyDim, QtCore.SIGNAL('triggered()'), self.setInfoStyleSt_OnlyDim);
        QtCore.QObject.connect(self.actionSt_NoInfo, QtCore.SIGNAL('triggered()'), self.setInfoStyleSt_NoInfo);
        QtCore.QObject.connect(self.actionEdge_AllInfo, QtCore.SIGNAL('triggered()'), self.setInfoStyleEdge_AllInfo);
        QtCore.QObject.connect(self.actionEdge_OnlyProb, QtCore.SIGNAL('triggered()'), self.setInfoStyleEdge_OnlyProb);
        QtCore.QObject.connect(self.actionEdge_NoInfo, QtCore.SIGNAL('triggered()'), self.setInfoStyleEdge_NoInfo);
        QtCore.QObject.connect(self.actionAct_OnlyQ, QtCore.SIGNAL('triggered()'), self.setInfoStyleAct_OnlyQ);
        QtCore.QObject.connect(self.actionAct_OnlyId, QtCore.SIGNAL('triggered()'), self.setInfoStyleAct_OnlyId);
        QtCore.QObject.connect(self.actionAct_NoInfo, QtCore.SIGNAL('triggered()'), self.setInfoStyleAct_NoInfo);
        QtCore.QObject.connect(self.actionGraph, QtCore.SIGNAL('triggered()'), self.showGraph);
        QtCore.QObject.connect(self.actionGraphSettings, QtCore.SIGNAL('triggered()'), self.showGraphSettings);
        
        #Graph Actions
        self.actionAnimateTrans = QtGui.QAction(QtGui.QIcon('Images/animate.png'), 'Animate Transition', self.parent);
        self.actionLayoutGrid = QtGui.QAction(QtGui.QIcon('Images/layout_Grid.png'), 'Layout Grid', self.parent);
        self.actionLayoutFlow = QtGui.QAction(QtGui.QIcon('Images/layout_Flow.png'), 'Layout Flow', self.parent);
        self.actionLayoutCircle = QtGui.QAction(QtGui.QIcon('Images/layout_Circle.png'), 'Layout Circle', self.parent);
        self.actionLayoutCurve = QtGui.QAction(QtGui.QIcon('Images/layout_Curve.png'), 'Layout GraphViz', self.parent);
        self.actionThemeGeneric = QtGui.QAction('Generic', self.parent);
        self.actionThemeMaze = QtGui.QAction('Maze', self.parent);        
        self.actionSt_Normal = QtGui.QAction('Normal', self.parent);
        self.actionSt_Current = QtGui.QAction('Current', self.parent);
        self.actionSt_Goal = QtGui.QAction('Goal', self.parent);
        self.actionSt_Fatal = QtGui.QAction('Fatal', self.parent);
        self.actionAct_Normal = QtGui.QAction('Normal', self.parent);
        self.actionAct_Current = QtGui.QAction('Current', self.parent);
        self.actionAct_Best = QtGui.QAction('Best', self.parent); 
        self.actionAct_Risky = QtGui.QAction('Risky', self.parent);        
        self.actionSt_Circle = QtGui.QAction('Circle', self.parent);
        self.actionSt_Rect = QtGui.QAction('Rect', self.parent);
        self.actionSt_RoundedRect = QtGui.QAction('Rounded Rect', self.parent);
        self.actionEdge_Spline = QtGui.QAction(QtGui.QIcon('Images/spline.png'), 'Spline', self.parent);
        self.actionEdge_Polygon = QtGui.QAction(QtGui.QIcon('Images/polygon.png'), 'Polygon', self.parent);        
        self.actionMovable = QtGui.QAction('Movable', self.parent);
        self.actionMovable.setCheckable(True);
        self.actionSelectable = QtGui.QAction('Selectable', self.parent);
        self.actionSelectable.setCheckable(True);
#         self.actionStBkgColor_None = QtGui.QAction('None', self.parent);
#         self.actionStBkgColor_None.setCheckable(True);
#         self.actionStBkgColor_None.setChecked(True);
#         self.actionStBkgColor_ByVal = QtGui.QAction('Value', self.parent);
#         self.actionStBkgColor_ByVal.setCheckable(True);
#         self.actionStBkgColor_ByR = QtGui.QAction('Reward', self.parent);
#         self.actionStBkgColor_ByR.setCheckable(True);
#         self.actionStBkgColor_ByD = QtGui.QAction('Distance', self.parent);
#         self.actionStBkgColor_ByD.setCheckable(True);
#         self.actionStBkgColor_ByDim = QtGui.QAction('By Dimension...', self.parent);
#         self.actionStBkgColor_ByDim.setCheckable(True);
#         self.actionActBkgColor_None = QtGui.QAction('None', self.parent);
#         self.actionActBkgColor_None.setCheckable(True);
#         self.actionActBkgColor_None.setChecked(True);
#         self.actionActBkgColor_ByQ = QtGui.QAction('Q-Value', self.parent);
#         self.actionActBkgColor_ByQ.setCheckable(True);
#         self.actionActPolicy = QtGui.QAction('Policy', self.parent);
#         self.actionActPolicy.setCheckable(True);
#         self.actionActShowMaxProbs = QtGui.QAction('Max-T', self.parent);
#         self.actionActShowMaxProbs.setCheckable(True);
#         self.actionActShowNormalProbs = QtGui.QAction('None', self.parent);
#         self.actionActShowNormalProbs.setCheckable(True);
#         self.actionActShowNormalProbs.setChecked(True);
        self.actionActsFront = QtGui.QAction('Send Actions to Front', self.parent);
        self.actionActsFront.setCheckable(True);
        self.actionEdgesFront = QtGui.QAction('Send Edges to Front', self.parent);
        self.actionEdgesFront.setCheckable(True);
        self.actionHideActs = QtGui.QAction('Hide Actions', self.parent);
        self.actionHideActs.setCheckable(True);
        self.actionHideEdges = QtGui.QAction('Hide Edges', self.parent);
        self.actionHideEdges.setCheckable(True);
        self.actionAlign_Left = QtGui.QAction(QtGui.QIcon('Images/align_Left.png'), 'Left', self.parent);
        self.actionAlign_Right = QtGui.QAction(QtGui.QIcon('Images/align_Right.png'), 'Right', self.parent);
        self.actionAlign_CenterH = QtGui.QAction(QtGui.QIcon('Images/align_CenterH.png'), 'Center Horizontal', self.parent);
        self.actionAlign_CenterV = QtGui.QAction(QtGui.QIcon('Images/align_CenterV.png'), 'Center Vertical', self.parent);
        self.actionAlign_Top = QtGui.QAction(QtGui.QIcon('Images/align_Top.png'), 'Top', self.parent);
        self.actionAlign_Bottom = QtGui.QAction(QtGui.QIcon('Images/align_Bottom.png'), 'Bottom', self.parent);        
        QtCore.QObject.connect(self.actionAnimateTrans, QtCore.SIGNAL('triggered()'), self.animateTrans);
        QtCore.QObject.connect(self.actionLayoutGrid, QtCore.SIGNAL('triggered()'), self.layoutGrid);
        QtCore.QObject.connect(self.actionLayoutFlow, QtCore.SIGNAL('triggered()'), self.layoutFlow);
        QtCore.QObject.connect(self.actionLayoutCircle, QtCore.SIGNAL('triggered()'), self.layoutCircle);
        QtCore.QObject.connect(self.actionLayoutCurve, QtCore.SIGNAL('triggered()'), self.layoutCurve);
        QtCore.QObject.connect(self.actionSt_Normal, QtCore.SIGNAL('triggered()'), self.setStatusTypeSt_Normal);
        QtCore.QObject.connect(self.actionSt_Current, QtCore.SIGNAL('triggered()'), self.setStatusTypeSt_Current);
        QtCore.QObject.connect(self.actionSt_Fatal, QtCore.SIGNAL('triggered()'), self.setStatusTypeSt_Fatal);
        QtCore.QObject.connect(self.actionSt_Goal, QtCore.SIGNAL('triggered()'), self.setStatusTypeSt_Goal);
        QtCore.QObject.connect(self.actionAct_Normal, QtCore.SIGNAL('triggered()'), self.setStatusTypeAct_Normal);
        QtCore.QObject.connect(self.actionAct_Current, QtCore.SIGNAL('triggered()'), self.setStatusTypeAct_Current);
        QtCore.QObject.connect(self.actionAct_Risky, QtCore.SIGNAL('triggered()'), self.setStatusTypeAct_Risky);
        QtCore.QObject.connect(self.actionAct_Best, QtCore.SIGNAL('triggered()'), self.setStatusTypeAct_Best);
        QtCore.QObject.connect(self.actionHideActs, QtCore.SIGNAL('triggered()'), self.hideActions);
        QtCore.QObject.connect(self.actionHideEdges, QtCore.SIGNAL('triggered()'), self.hideEdges);
        QtCore.QObject.connect(self.actionMovable, QtCore.SIGNAL('triggered()'), self.setMovable);
        QtCore.QObject.connect(self.actionSelectable, QtCore.SIGNAL('triggered()'), self.setSelectable);
        QtCore.QObject.connect(self.actionActsFront, QtCore.SIGNAL('triggered()'), self.setActionsFront);
        QtCore.QObject.connect(self.actionEdgesFront, QtCore.SIGNAL('triggered()'), self.setEdgesFront);
#         QtCore.QObject.connect(self.actionStBkgColor_None, QtCore.SIGNAL('triggered()'), self.setStBkgColor_None);
#         QtCore.QObject.connect(self.actionStBkgColor_ByVal, QtCore.SIGNAL('triggered()'), self.setStBkgColor_ByVal);
#         QtCore.QObject.connect(self.actionStBkgColor_ByR, QtCore.SIGNAL('triggered()'), self.setStBkgColor_ByR);
#         QtCore.QObject.connect(self.actionStBkgColor_ByD, QtCore.SIGNAL('triggered()'), self.setStBkgColor_ByD);
#         QtCore.QObject.connect(self.actionStBkgColor_ByDim, QtCore.SIGNAL('triggered()'), self.setStBkgColor_ByDim);
#         QtCore.QObject.connect(self.actionActBkgColor_None, QtCore.SIGNAL('triggered()'), self.setActBkgColor_None);
#         QtCore.QObject.connect(self.actionActBkgColor_ByQ, QtCore.SIGNAL('triggered()'), self.setActBkgColor_ByQ);
#         QtCore.QObject.connect(self.actionActPolicy, QtCore.SIGNAL('triggered()'), self.setActPolicy);
#         QtCore.QObject.connect(self.actionActShowNormalProbs, QtCore.SIGNAL('triggered()'), self.showNormalProbs);
#         QtCore.QObject.connect(self.actionActShowMaxProbs, QtCore.SIGNAL('triggered()'), self.showMaxProbs);
        QtCore.QObject.connect(self.actionEdge_Spline, QtCore.SIGNAL('triggered()'), self.setEdge_Spline);
        QtCore.QObject.connect(self.actionEdge_Polygon, QtCore.SIGNAL('triggered()'), self.setEdge_Polygon);
        QtCore.QObject.connect(self.actionSt_Circle, QtCore.SIGNAL('triggered()'), self.setSt_Circle);
        QtCore.QObject.connect(self.actionSt_Rect, QtCore.SIGNAL('triggered()'), self.setSt_Rect);
        QtCore.QObject.connect(self.actionSt_RoundedRect, QtCore.SIGNAL('triggered()'), self.setSt_RoundedRect);
        QtCore.QObject.connect(self.actionAlign_Left, QtCore.SIGNAL('triggered()'), self.alignNodesLeft);
        QtCore.QObject.connect(self.actionAlign_Right, QtCore.SIGNAL('triggered()'), self.alignNodesRight);
        QtCore.QObject.connect(self.actionAlign_CenterH, QtCore.SIGNAL('triggered()'), self.alignNodesCenterH);
        QtCore.QObject.connect(self.actionAlign_CenterV, QtCore.SIGNAL('triggered()'), self.alignNodesCenterV);
        QtCore.QObject.connect(self.actionAlign_Top, QtCore.SIGNAL('triggered()'), self.alignNodesTop);
        QtCore.QObject.connect(self.actionAlign_Bottom, QtCore.SIGNAL('triggered()'), self.alignNodesBottom);
        
        #Data Actions
        self.actionBuildGraph = QtGui.QAction(QtGui.QIcon('Images/buildGraph.png'), 'Build Graph (from Tables)', self.parent);
        self.actionGenerateTables = QtGui.QAction(QtGui.QIcon('Images/build_Tables.png'), 'Generate Tables (from Graph)', self.parent);
        self.actionBuildGraph_AllTables = QtGui.QAction('All Tables', self.parent);
        self.actionBuildGraph_Transition = QtGui.QAction('Transition', self.parent);
        self.actionBuildGraph_StateDim = QtGui.QAction('State Dimensions', self.parent);
        self.actionBuildGraph_StateInfo = QtGui.QAction('State Info', self.parent);
        self.actionBuildGraph_Rewards = QtGui.QAction('Rewards', self.parent);
        self.actionBuildGraph_QValue = QtGui.QAction('Q-Value', self.parent);
        self.actionGenerateTable_AllTables = QtGui.QAction('All Tables', self.parent);
        self.actionGenerateTable_Transition = QtGui.QAction('Transition', self.parent);
        self.actionGenerateTable_StateDim = QtGui.QAction('State Dimensions', self.parent);
        self.actionGenerateTable_StateInfo = QtGui.QAction('State Info', self.parent);
        self.actionGenerateTable_Rewards = QtGui.QAction('Rewards', self.parent);
        self.actionGenerateTable_QValue = QtGui.QAction('Q-Value', self.parent);
        QtCore.QObject.connect(self.actionGenerateTables, QtCore.SIGNAL('triggered()'), self.generateTables);
        QtCore.QObject.connect(self.actionGenerateTable_AllTables, QtCore.SIGNAL('triggered()'), self.generateTables);
        QtCore.QObject.connect(self.actionGenerateTable_Transition, QtCore.SIGNAL('triggered()'), self.generateTable_Transition);
        QtCore.QObject.connect(self.actionBuildGraph, QtCore.SIGNAL('triggered()'), self.buildGraph);
        
    
    #---All Commands----
    #File Cmds
    def newGraph(self):
        self.graphScene.removeGraph();
    def loadGraphData(self):
        self.dataContainer.loadData();
    def saveGraphData(self):
        self.dataContainer.saveData();
    def saveGraphDataAs(self):
        self.dataContainer.saveDataAs();
    def loadSettingsData(self):
        self.dataContainer.loadSettings();
    def saveSettingsData(self):
        self.dataContainer.saveSettings();
    
    #Hide/Show Sections Cmds
    def showGraph(self):
        mainWin = self.parent.mainWin.centralWidget();
        if mainWin!=None:
            mainWin.setVisible(True);
    def activateToolBarCmd(self, toolBar):
        QtCore.QObject.connect(self.actionToolbar, QtCore.SIGNAL('triggered()'), toolBar.showToolBar);
    def showGraphSettings(self):
        self.parent.graphSettings.myDockWidget.setVisible(True);
        
    #Select Cmds
    def selectGraph(self):
        self.graphScene.graphView.selectGraph(True);        
    def selectNodes(self):
        self.graphScene.graphView.selectNodes(True);        
    def selectActions(self):
        self.graphScene.graphView.selectActions(True);        
    def selectEdges(self):
        self.graphScene.graphView.selectEdges(True);
    
    #Edit Cmds    
    def addEdgeCtrlPt(self):
        self.graphScene.createCtrlPoint(self.graphScene.mousePos);        
    def setInfoStyleSt_AllInfo(self):
        self.graphScene.graphView.setNodes_StyleInfo(0);
    def setInfoStyleSt_HideV(self):
        self.graphScene.graphView.setNodes_StyleInfo(1);    
    def setInfoStyleSt_HideR(self):
        self.graphScene.graphView.setNodes_StyleInfo(2);      
    def setInfoStyleSt_OnlyR(self):
        self.graphScene.graphView.setNodes_StyleInfo(3);
    def setInfoStyleSt_OnlyV(self):
        self.graphScene.graphView.setNodes_StyleInfo(4);
    def setInfoStyleSt_OnlyDim(self):
        self.graphScene.graphView.setNodes_StyleInfo(5);
    def setInfoStyleSt_NoInfo(self):
        self.graphScene.graphView.setNodes_StyleInfo(6);
    def setInfoStyleEdge_AllInfo(self):
        self.graphScene.graphView.setEdges_StyleInfo(0);
    def setInfoStyleEdge_OnlyProb(self):
        self.graphScene.graphView.setEdges_StyleInfo(0);
    def setInfoStyleEdge_NoInfo(self):
        self.graphScene.graphView.setEdges_StyleInfo(1);
    def setInfoStyleAct_OnlyQ(self):
        self.graphScene.graphView.setActions_StyleInfo(0);   
    def setInfoStyleAct_OnlyId(self):
        self.graphScene.graphView.setActions_StyleInfo(1);
    def setInfoStyleAct_NoInfo(self):
        self.graphScene.graphView.setActions_StyleInfo(2);
        
    #Graph - Shape Style Cmds        
    def setSt_Rect(self):
        self.graphScene.graphView.setNodes_StateShape(0);      
    def setSt_RoundedRect(self):
        self.graphScene.graphView.setNodes_StateShape(15);
    def setSt_Circle(self):
        self.graphScene.graphView.setNodes_StateShape(80); 
    def setEdge_Polygon(self):
        self.graphScene.graphView.setEdges_LineType(1);
    def setEdge_Spline(self):
        self.graphScene.graphView.setEdges_LineType(2);
        
    #Graph - StatusType Cmds
    def setStatusTypeSt_Normal(self):
        self.graphScene.graphView.setNodes_StyleStatus(0);
    def setStatusTypeSt_Current(self):
        self.graphScene.graphView.setNodes_StyleStatus(1);
    def setStatusTypeSt_Fatal(self):
        self.graphScene.graphView.setNodes_StyleStatus(2);
    def setStatusTypeSt_Goal(self):
        self.graphScene.graphView.setNodes_StyleStatus(3);
    def setStatusTypeAct_Normal(self):
        self.graphScene.graphView.setActions_StyleStatus(0);
    def setStatusTypeAct_Current(self):
        self.graphScene.graphView.setActions_StyleStatus(1);
    def setStatusTypeAct_Risky(self):
        self.graphScene.graphView.setActions_StyleStatus(2);
    def setStatusTypeAct_Best(self):
        self.graphScene.graphView.setActions_StyleStatus(3);
        
    #Window - Settings
    def showGrpActVals(self):
        self.dataView.gridGrpActsTbl.myDockWidget.setVisible(True);
#     def showMdpAndRisks(self):
#         self.dataView.gridMdpRiskInfo.myDockWidget.setVisible(True);        
#     def showStateInfo(self):
#         self.dataView.gridStInfo.myDockWidget.setVisible(True);
#     def showStateTrans(self):
#         self.dataView.gridStTrans.myDockWidget.setVisible(True);  
#     def showStateDists(self):
#         self.dataView.gridStDists.myDockWidget.setVisible(True);    
#     def showMdpTraceEv(self):
#         self.dataView.gridStTraceEvents.myDockWidget.setVisible(True);
#     def showGralMdpVals(self):
#         self.dataView.gridMdpParams.myDockWidget.setVisible(True);
#     def showRiskActRes(self):
#         self.dataView.gridRiskActRes.myDockWidget.setVisible(True);        
    def showFullScreenMode(self):
        if not self.parent.mainWin.isFullScreen():
            self.parent.mainWin.showFullScreen();
        else:
            self.parent.mainWin.showNormal();
        
    #Graph - Settings
    def setMovable(self):
        self.graphScene.graphView.setNodesMovable(not self.actionMovable.isChecked());
    def setSelectable(self):
        self.graphScene.graphView.setNodesSelectable(not self.actionSelectable.isChecked());
    def hideActions(self):
        self.graphScene.hideActions(not self.actionHideActs.isChecked());
    def hideEdges(self):
        self.graphScene.graphView.setEdgesVisible(not self.graphScene.graphView.bEdgesVisible);
    def setActionsFront(self):
        self.graphScene.graphView.setActionsBack(not self.actionActsFront.isChecked());
    def setEdgesFront(self):
        if not self.actionEdgesFront.isChecked():
            self.graphScene.graphView.setEdgesZVal(-0.2);
        else:
            self.graphScene.graphView.setEdgesZVal(0.2);
            
    #Graph - Background Color
#     def setStBkgColor_None(self):
#         self.graphScene.graphView.setNodes_BkgColorType(0);
#         self.clearStBkgColors();
#         self.actionStBkgColor_None.setChecked(True);
#     def setStBkgColor_ByVal(self):
#         nMaxV = self.dataModel.nMaxV;
#         nMinV = self.dataModel.nMinV;
#         self.graphScene.graphView.setNodes_BkgColorType(1, nMaxV, nMinV);
#         self.clearStBkgColors();
#         self.actionStBkgColor_ByVal.setChecked(True);
#     def setStBkgColor_ByR(self):
#         nMaxR = self.dataModel.nMaxR;
#         nMinR = self.dataModel.nMinR;
#         self.graphScene.graphView.setNodes_BkgColorType(2, nMaxR, nMinR);
#         self.clearStBkgColors();
#         self.actionStBkgColor_ByR.setChecked(True);
#     def setStBkgColor_ByD(self):
#         nMaxD = self.dataModel.nMaxD;
#         self.graphScene.graphView.setNodes_BkgColorType(4, nMaxD);
#         self.clearStBkgColors();
#         self.actionStBkgColor_ByD.setChecked(True);
#     def setStBkgColor_ByDim(self):
#         self.graphScene.graphView.setNodes_BkgColorType(3, 10,0, 0);
#         self.clearStBkgColors();
#         self.actionStBkgColor_ByDim.setChecked(True);
#     def setActBkgColor_None(self):
#         self.graphScene.graphView.setActions_BkgColorType(0);
#         self.clearActBkgColors();
#         self.actionActBkgColor_None.setChecked(True);
#     def setActBkgColor_ByQ(self):
#         aMaxQ = self.dataModel.nMaxQ;
#         aMinQ = self.dataModel.nMinQ;
#         self.graphScene.graphView.setActions_BkgColorType(1, aMaxQ, aMinQ);
#         self.clearActBkgColors();
#         self.actionActBkgColor_ByQ.setChecked(True);
#     def setActPolicy(self):
#         self.clearActBkgColors();
#         self.graphScene.graphView.setActions_PolicyMode(True);
#         self.actionActPolicy.setChecked(True);
#     def showNormalProbs(self):
#         self.graphScene.graphView.showMaxProbEdges(False);
#         self.clearShowDistProbs();
#         self.actionActShowNormalProbs.setChecked(True);
#     def showMaxProbs(self):
#         self.graphScene.graphView.showMaxProbEdges(True);
#         self.clearShowDistProbs();
#         self.actionActShowMaxProbs.setChecked(True);        
#     def clearStBkgColors(self):
#         self.actionStBkgColor_None.setChecked(False);
#         self.actionStBkgColor_ByVal.setChecked(False);
#         self.actionStBkgColor_ByR.setChecked(False);
#         self.actionStBkgColor_ByD.setChecked(False);
#     def clearActBkgColors(self):
#         self.actionActBkgColor_None.setChecked(False);
#         self.actionActBkgColor_ByQ.setChecked(False);
#         self.graphScene.graphView.setActions_PolicyMode(False);
#         self.actionActPolicy.setChecked(False);
#     def clearShowDistProbs(self):
#         self.actionActShowMaxProbs.setChecked(False);
#         self.actionActShowNormalProbs.setChecked(False);
#     def updateBkgColors(self):
#         if self.actionStBkgColor_None.isChecked():
#             self.setStBkgColor_None();
#         elif self.actionStBkgColor_ByVal.isChecked():
#             self.setStBkgColor_ByVal();
#         elif self.actionStBkgColor_ByR.isChecked():
#             self.setStBkgColor_ByR();
#         elif self.actionStBkgColor_ByD.isChecked():
#             self.setStBkgColor_ByD();
#         if self.actionActBkgColor_None.isChecked():
#             self.setActBkgColor_None();
#         elif self.actionActBkgColor_ByQ.isChecked():
#             self.setActBkgColor_ByQ();
#         elif self.actionActPolicy.isChecked():
#             self.setActPolicy();
#         if self.actionActShowNormalProbs.isChecked():
#             self.showNormalProbs();
#         elif self.actionActShowMaxProbs.isChecked():
#             self.showMaxProbs();
    def getDataSettings(self):
        aDataSettings = [];
#         aDataSettings.append(self.actionStBkgColor_None.isChecked());
#         aDataSettings.append(self.actionStBkgColor_ByVal.isChecked());
#         aDataSettings.append(self.actionStBkgColor_ByR.isChecked());
#         aDataSettings.append(self.actionStBkgColor_ByD.isChecked());
#         aDataSettings.append(self.actionActBkgColor_None.isChecked());
#         aDataSettings.append(self.actionActBkgColor_ByQ.isChecked());
#         aDataSettings.append(self.actionActPolicy.isChecked());
#         aDataSettings.append(self.actionActShowMaxProbs.isChecked());
#         aDataSettings.append(self.actionActShowNormalProbs.isChecked());
        return aDataSettings;
    def setDataSettings(self, aSettings):
#         self.actionStBkgColor_None.setChecked(aSettings[0]);
#         self.actionStBkgColor_ByVal.setChecked(aSettings[1]);
#         self.actionStBkgColor_ByR.setChecked(aSettings[2]);
#         self.actionStBkgColor_ByD.setChecked(aSettings[3]);
#         self.actionActBkgColor_None.setChecked(aSettings[4]);
#         self.actionActBkgColor_ByQ.setChecked(aSettings[5]);
#         self.actionActPolicy.setChecked(aSettings[6]);
#         self.actionActShowMaxProbs.setChecked(aSettings[7]);
#         self.actionActShowNormalProbs.setChecked(aSettings[8]);
#         self.updateBkgColors();
        pass;
            
        
        
    #Graph - Align Nodes    
    def alignNodesLeft(self):
        self.graphScene.graphView.alignNodesLeft();
    def alignNodesRight(self):
        self.graphScene.graphView.alignNodesRight();
    def alignNodesCenterH(self):
        self.graphScene.graphView.alignNodesCenterH();
    def alignNodesCenterV(self):
        self.graphScene.graphView.alignNodesCenterV();
    def alignNodesTop(self):
        self.graphScene.graphView.alignNodesTop();
    def alignNodesBottom(self):
        self.graphScene.graphView.alignNodesBottom();
        
    
    #Layout Cmds
    def layoutCurve(self):
        self.parent.layoutSettings.showTab(0);
    def layoutCircle(self):
        self.parent.layoutSettings.showTab(1);
    def layoutGrid(self):
        self.parent.layoutSettings.showTab(2);
    def layoutFlow(self):
        self.parent.layoutSettings.showTab(3);
#    def layoutGrid(self):
#        self.graphScene.graphView.applyGraphLayout(0);    
#    def layoutFlow(self):
#        self.graphScene.graphView.applyGraphLayout(1);        
#    def layoutCircle(self):
#        self.graphScene.graphView.applyGraphLayout(2);        
#    def layoutCurve(self):
#        self.graphScene.graphView.applyGraphLayout(3); 
        
    def animateTrans(self):
        self.parent.stTraceEvents.showTab(0);
#        self.graphScene.graphView.animTrans(1, 0, 2, 4000, GraphSceneView.animType.OutBounce);
#        self.graphScene.graphView.animTrans(1, 0, 0, 4000, GraphSceneView.animType.OutBounce);
#        for i in range(len(self.graphScene.gNodes)):
#            print self.graphScene.gNodes[i], self.graphScene.gNodes[i].actions[0], self.graphScene.gEdges[i];
#        self.graphScene.removeGraph();
#        print "Edges: ", len(self.graphScene.edges);#, self.graphScene.edges[0].objTo;
#        print "Nodes: ", len(self.graphScene.nodes);     


    #Data Cmds
    def generateTables(self):
        self.dataContainer.updateDataFromGraph();
        self.dataContainer.dataView.updateGridTables();
    
    def generateTable_Transition(self):
        pass;
#        self.dataContainer.updateDataFromGraph();
#        self.dataContainer.dataView.gridStTrans.updateGrid();
        
    def buildGraph(self):
        self.dataContainer.updateGraph();
